package net.jeeshop.services.manage.sku.dao.impl;

import net.jeeshop.core.common.dao.BaseDao;
import net.jeeshop.core.common.dao.page.PagerModel;
import net.jeeshop.services.manage.sku.bean.Sku;
import net.jeeshop.services.manage.sku.dao.SkuDao;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description
 * @Author semstouch
 * @Date 2017/3/28
 **/
@Repository("skuDaoManage")
public class SkuDaoImpl implements SkuDao{
    @Resource
    private BaseDao dao;

    public void setDao(BaseDao dao) {
        this.dao = dao;
    }

    @Override
    public int insert(Sku sku) {
        return dao.insert("manage.sku.insert", sku);
    }

    @Override
    public int delete(Sku sku) {
        return dao.delete("manage.sku.deleteById", sku);
    }

    @Override
    public int update(Sku sku) {
        return dao.update("manage.sku.update",sku);    }

    @Override
    public Sku selectOne(Sku sku) {
        return (Sku) dao.selectOne("manage.sku.selectOne", sku);
    }

    @Override
    public PagerModel selectPageList(Sku sku){
        return dao.selectPageList("manage.sku.selectPageList",
            "manage.sku.selectPageCount", sku);
    }

    @Override
    public List selectList(Sku sku) {
        return dao.selectList("manage.sku.selectList", sku);
    }

    @Override
    public int deleteById(int id) {
        return dao.delete("manage.sku.deleteById", id);
    }

    @Override
    public Sku selectById(String id) {
        return (Sku) dao.selectOne("manage.sku.selectById", id);
    }

    public int deletes(String[] ids) {
        Sku e = new Sku();
        for (int i = 0; i < ids.length; i++) {
            e.setId(ids[i]);
            delete(e);
        }
        return 0;
    }
}
